import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import React from "react";
import { Input, Select } from "antd";
import { CpasIcon } from "~/public/cpas-ui";
export default class RowFilterCondition extends React.Component {
    constructor(props) {
        super(props);
        this.getText1 = this.getText1.bind(this);
        this.getText2 = this.getText2.bind(this);
        this.state = {
            text1: "且",
            fieldList: [],
            condionList: [],
            leftKuohao: "",
            rightKuohao: "",
            filterVal: "",
            filterField: "",
            condions: "",
            getWheres: {},
        };
    }
    // 底稿结构化 -- 筛选 -- 左括号
    getText1(e) {
        if (e.target.value === "") {
            this.setState({
                leftKuohao: "(",
            });
        }
        else {
            this.setState({
                leftKuohao: "",
            });
        }
        // 把值通过下面方法传给父亲
        this.formulaCondion();
        // this.props.getWheres(this.formulaCondion()); // 执行到父组件
    }
    // 底稿结构化 -- 筛选 -- 右括号
    getText2(e) {
        if (e.target.value == "") {
            this.setState({
                rightKuohao: ")",
            });
        }
        else {
            this.setState({
                rightKuohao: "",
            });
        }
        // 把值通过下面方法传给父亲
        this.formulaCondion();
        // this.props.getWheres(this.formulaCondion()); // 执行到父组件
    }
    // 底稿结构化 -- 筛选 条件 且 或
    ckText() {
        this.setState({
            text1: this.state.text1 === "且" ? "或" : "且",
        });
        // 把值通过下面方法传给父亲
        this.formulaCondion();
        // this.props.getWheres(this.formulaCondion()); // 执行到父组件
    }
    // 底稿结构化 -- 筛选 - 列字段名称列表 为dev表的表头  this.props.columnsData
    trasferField() {
        let columnsData = [
            { dataField: "主键", caption: "主键" },
            { dataField: "项目", caption: "项目" },
            { dataField: "办公设备", caption: "办公设备" },
            { dataField: "房屋及建筑物", caption: "房屋及建筑物" },
            { dataField: "机器设备", caption: "机器设备" },
            { dataField: "其他设备", caption: "其他设备" },
            { dataField: "运输设备", caption: "运输设备" },
        ];
        const fields = columnsData.map((item) => {
            return { value: item.name, label: item.name };
        });
        this.setState({
            fieldList: fields,
        });
    }
    // 底稿结构化 --筛选 列字段下拉事件
    changeField(val) {
        this.setState({
            filterField: val,
        });
        // 把值通过下面方法传给父亲
        this.formulaCondion();
        // this.props.getWheres(this.formulaCondion()); // 执行到父组件
    }
    // 底稿结构化 -- 筛选 条件下拉框
    conditionOptions() {
        const condionList = [
            {
                value: "前几项",
                label: "前几项",
            },
            {
                value: "后几项",
                label: "后几项",
            },
            {
                value: "=",
                label: "等于",
            },
            {
                value: "!=",
                label: "不等于",
            },
            {
                value: ">",
                label: "大于",
            },
            {
                value: ">=",
                label: "大于或等于",
            },
            {
                value: "<",
                label: "小于",
            },
            {
                value: "<=",
                label: "小于或等于",
            },
            {
                value: "like %d%",
                label: "包含",
            },
            {
                value: "not like %d%",
                label: "不包含",
            },
        ];
        this.setState({
            condionList: condionList,
        });
    }
    // 底稿结构化 -- 筛选 条件下拉点击
    changeCondion(val) {
        this.setState({
            condions: val,
        });
        // 把值通过下面方法传给父亲
        this.formulaCondion();
        // this.props.getWheres(this.formulaCondion()); // 执行到父组件
    }
    // 底搞结构化 -- 筛选 -- 输入值
    getInpVal(e) {
        this.setState({
            filterVal: e.target.value,
        });
        // 把值通过下面方法传给父亲
        this.formulaCondion();
        // this.props.getWheres(this.formulaCondion()); // 执行到父组件
    }
    // 组装公式-- 附加条件
    formulaCondion() {
        // 筛选 - 且/或 this.state.text1
        // 左括号 - this.state.leftKuohao
        // 右括号 - this.state.rightKuohao
        // 列字段名称 - this.state.filterField
        // 条件 - this.state.condions
        // 值 - this.state.filterVal
        // console.log("333--strArr 2222", strArr);
        let obj = {
            text1: this.state.text1,
            leftKuohao: this.state.leftKuohao,
            rightKuohao: this.state.rightKuohao,
            filterField: this.state.filterField,
            condions: this.state.condions,
            filterVal: this.state.filterVal,
        };
        console.log("333--obj", obj);
        return obj;
    }
    render() {
        return (_jsx(_Fragment, { children: _jsx("div", { className: "addRows", children: _jsxs("div", { className: "flex-start", children: [_jsxs("div", { className: "flex-col mr-8", children: [_jsx("div", { style: {
                                        border: "0px solid #000",
                                        width: "30px",
                                        height: "28px",
                                    }, children: " " }), _jsx("div", { className: "fang cur", onClick: this.ckText, children: this.state.text1 })] }), _jsxs("div", { className: "flex-col mr-8", children: [_jsx("div", { children: "\u62EC\u5F27" }), _jsx("div", { className: "w30", children: _jsx(Input, { type: "text", value: this.state.leftKuohao, defaultValue: this.state.leftKuohao, onFocus: this.getText1 }) })] }), _jsxs("div", { className: "flex-col mr-8", children: [_jsx("div", { children: "\u5217\u5B57\u6BB5\u540D\u79F0" }), _jsx("div", { className: "", children: _jsx(Select, { defaultValue: "", value: this.state.filterField, style: { width: 100 }, options: this.state.fieldList, onChange: this.changeField }) })] }), _jsxs("div", { className: "flex-col mr-8", children: [_jsx("div", { children: "\u6761\u4EF6" }), _jsx("div", { className: "", children: _jsx(Select, { defaultValue: "", value: this.state.condions, style: { width: 100 }, options: this.state.condionList, onChange: this.changeCondion }) })] }), _jsxs("div", { className: "flex-col mr-8", children: [_jsx("div", { children: "\u503C" }), _jsx("div", { className: "", children: _jsx(Input, { type: "text", value: this.state.filterVal, onChange: this.getInpVal }) })] }), _jsxs("div", { className: "flex-col mr-8", children: [_jsx("div", { children: "\u62EC\u5F27" }), _jsx("div", { className: "w30", children: _jsx(Input, { type: "text", value: this.state.rightKuohao, defaultValue: this.state.rightKuohao, onFocus: this.getText2 }) })] }), _jsxs("div", { className: "flex-col cur", children: [_jsx("div", { style: {
                                        border: "0px solid #000",
                                        width: "30px",
                                        height: "28px",
                                    } }), _jsx(CpasIcon, { className: "icon-size16", type: "icon-delete" })] })] }) }) }));
    }
}
